home *** CD-ROM | disk | FTP | other *** search
- package com.extensibility.exv;
-
- import com.extensibility.xml.XMLWriter;
- import java.io.File;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.Serializable;
- import java.io.Writer;
- import java.util.Hashtable;
- import java.util.Random;
- import java.util.Vector;
-
- public abstract class MultiModule implements Serializable {
- public static final int FLAVOR_STRARRAY = 0;
- public static final int FLAVOR_ZIP = 1;
- int flavor;
- boolean persistent = false;
- private static String ROOT_PATH = "d:\\tmp";
- File localDir;
- protected Hashtable validValues = new Hashtable();
- protected Hashtable wfValues = new Hashtable();
- protected Hashtable errors = new Hashtable();
- protected boolean[] map;
- protected String[] fileNameMap;
-
- public MultiModule(int var1, boolean var2) {
- this.flavor = var1;
- this.localDir = new File(ROOT_PATH, this.getRandomPath());
- this.persistent = true;
- }
-
- public Hashtable getValidValues() {
- return (Hashtable)this.validValues.clone();
- }
-
- public Hashtable getWfValues() {
- return (Hashtable)this.wfValues.clone();
- }
-
- public boolean getParseable(int var1) throws ArrayIndexOutOfBoundsException {
- return this.map[var1];
- }
-
- public boolean getParseable(String var1) throws ArrayIndexOutOfBoundsException {
- return this.getParseable(this.getIndexOfSchema(var1));
- }
-
- public void setParseable(int var1, boolean var2) throws ArrayIndexOutOfBoundsException {
- this.map[var1] = var2;
- }
-
- public void setParseable(String var1, boolean var2) throws ArrayIndexOutOfBoundsException {
- this.setParseable(this.getIndexOfSchema(var1), var2);
- }
-
- public int getNotParseableCount() {
- int var1 = 0;
-
- for(int var2 = 0; var2 < this.map.length; ++var2) {
- if (!this.map[var2]) {
- ++var1;
- }
- }
-
- return var1;
- }
-
- public boolean[] getMap() {
- return this.map;
- }
-
- public void setMap(boolean[] var1) throws SchemaException {
- if (var1 == null) {
- throw new SchemaException("Invalid map");
- } else {
- this.map = var1;
- }
- }
-
- public void setMap(int var1, boolean var2) throws SchemaException {
- if (var1 < 0) {
- throw new SchemaException("Invalid map size");
- } else {
- this.map = new boolean[var1];
-
- for(int var3 = 0; var3 < var1; ++var3) {
- this.map[var3] = var2;
- }
-
- }
- }
-
- public boolean isEmpty() {
- return this.fileNameMap.length == 0;
- }
-
- public int size() {
- return this.fileNameMap.length;
- }
-
- public void clear() {
- if (this.persistent) {
- System.gc();
- this.clearDir(this.localDir);
- this.localDir.delete();
- }
-
- }
-
- void saveToFile(String[] var1, String[] var2) throws IOException {
- this.localDir.mkdir();
-
- for(int var3 = 0; var3 < var1.length; ++var3) {
- XMLWriter var4 = new XMLWriter(new FileOutputStream(new File(this.localDir, var1[var3])));
- ((Writer)var4).write(var2[var3]);
- var4.flush();
- var4.close();
- }
-
- }
-
- Vector retDeclErrors(String var1) throws SchemaException {
- if (!this.errors.containsKey(var1)) {
- throw new SchemaException("The schema was not validated.");
- } else {
- return (Vector)((SchemaAllErrors)this.errors.get(var1)).getDeclErrors().clone();
- }
- }
-
- int retDeclErrorsCount(String var1) throws SchemaException {
- if (!this.errors.containsKey(var1)) {
- throw new SchemaException("The schema was not validated.");
- } else {
- return ((SchemaAllErrors)this.errors.get(var1)).getDeclErrors().size();
- }
- }
-
- Vector retParseErrors(String var1) throws SchemaException {
- if (!this.errors.containsKey(var1)) {
- throw new SchemaException("The schema was not validated.");
- } else {
- return (Vector)((SchemaAllErrors)this.errors.get(var1)).getParseErrors().clone();
- }
- }
-
- int retParseErrorsCount(String var1) throws SchemaException {
- if (!this.errors.containsKey(var1)) {
- throw new SchemaException("The schema was not validated.");
- } else {
- return ((SchemaAllErrors)this.errors.get(var1)).getParseErrors().size();
- }
- }
-
- Vector retDeclErrorsDesc(String var1) throws SchemaException {
- if (!this.errors.containsKey(var1)) {
- throw new SchemaException("The schema was not validated.");
- } else {
- return (Vector)((SchemaAllErrors)this.errors.get(var1)).getDeclErrorsDesc().clone();
- }
- }
-
- Vector retParseErrorsDesc(String var1) throws SchemaException {
- if (!this.errors.containsKey(var1)) {
- throw new SchemaException("The schema was not validated.");
- } else {
- return (Vector)((SchemaAllErrors)this.errors.get(var1)).getParseErrorsDesc().clone();
- }
- }
-
- String getPath() {
- return ROOT_PATH;
- }
-
- void setPath(String var1) {
- if (var1 != null) {
- ROOT_PATH = var1;
- }
-
- }
-
- protected void initFileNameMap(String[] var1) {
- this.fileNameMap = new String[var1.length];
-
- for(int var2 = 0; var2 < var1.length; ++var2) {
- this.fileNameMap[var2] = var1[var2];
- }
-
- }
-
- protected int getIndexOfSchema(String var1) {
- for(int var2 = 0; var2 < this.fileNameMap.length; ++var2) {
- if (this.fileNameMap[var2].equals(var1)) {
- return var2;
- }
- }
-
- return -1;
- }
-
- private void clearDir(File var1) {
- String[] var2 = var1.list();
-
- for(int var3 = 0; var3 < var2.length; ++var3) {
- File var4 = new File(var1, var2[var3]);
- if (var4.isDirectory()) {
- this.clearDir(var4);
- }
-
- var4.delete();
- }
-
- }
-
- private String getRandomPath() {
- Random var1 = new Random(System.currentTimeMillis());
- StringBuffer var2 = new StringBuffer();
-
- for(int var3 = 0; var3 < 10; ++var3) {
- var2.append((char)(97 + (int)(var1.nextFloat() * (float)25)));
- }
-
- return var2.toString();
- }
-
- abstract void changedSchema(String var1);
-
- public abstract int countFlavor(String var1);
-
- public abstract Vector getSchemas();
-
- public abstract SchemaWrapper getSchema(String var1) throws SchemaException;
-
- public abstract void validate();
-
- public abstract void validate(String var1) throws SchemaException;
-
- public abstract boolean isValid() throws SchemaException;
-
- public abstract boolean isValid(String var1) throws SchemaException;
-
- public abstract boolean isWellFormed() throws SchemaException;
-
- public abstract boolean isWellFormed(String var1) throws SchemaException;
-
- public abstract String getResults(String var1) throws SchemaException;
-
- public abstract Vector getValidSchemas();
-
- public abstract Vector getNotValidSchemas();
-
- public abstract Vector getWfSchemas();
-
- public abstract Vector getNotWfSchemas();
-
- public abstract Vector getNotParseable();
-
- public abstract Vector getDeclErrors(String var1) throws SchemaException;
-
- public abstract Vector getParseErrors(String var1) throws SchemaException;
-
- public abstract Vector getDeclErrorsDesc(String var1) throws SchemaException;
-
- public abstract Vector getParseErrorsDesc(String var1) throws SchemaException;
- }
-